package com.ruoyi.web.controller.ydz;

import java.util.List;

import com.ruoyi.web.domain.NewsTdk;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.JapanNewsTdk;
import com.ruoyi.web.service.IJapanNewsTdkService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日本新闻tdk配置Controller
 * 
 * @author drx
 * @date 2024-03-22
 */
@Controller
@RequestMapping("/ydz/japanNewsTdk")
@Api(tags = "日本新闻tdk配置")
public class JapanNewsTdkController extends BaseController
{
    private String prefix = "ydz/japanNewsTdk";

    @Autowired
    private IJapanNewsTdkService japanNewsTdkService;

    @RequiresPermissions("ydz:japanNewsTdk:view")
    @GetMapping()
    public String japanNewsTdk()
    {
        return prefix + "/japanNewsTdk";
    }

    /**
     * 查询日本新闻tdk配置列表
     */
    @RequiresPermissions("ydz:japanNewsTdk:list")
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation("查询日本新闻tdk配置列表")
    public TableDataInfo list(JapanNewsTdk japanNewsTdk)
    {
        startPage();
        List<JapanNewsTdk> list = japanNewsTdkService.selectJapanNewsTdkList(japanNewsTdk);
        return getDataTable(list);
    }

    /**
     * 导出日本新闻tdk配置列表
     */
    @RequiresPermissions("ydz:japanNewsTdk:export")
    @Log(title = "日本新闻tdk配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    @ApiOperation("导出日本新闻tdk配置列表")
    public AjaxResult export(JapanNewsTdk japanNewsTdk)
    {
        List<JapanNewsTdk> list = japanNewsTdkService.selectJapanNewsTdkList(japanNewsTdk);
        ExcelUtil<JapanNewsTdk> util = new ExcelUtil<JapanNewsTdk>(JapanNewsTdk.class);
        return util.exportExcel(list, "日本新闻tdk配置数据");
    }

    /**
     * 新增日本新闻tdk配置
     */
    @GetMapping("/add")
    @ApiOperation("新增日本新闻tdk配置")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存日本新闻tdk配置
     */
    @ApiOperation("新增保存日本新闻tdk配置")
    @RequiresPermissions("ydz:japanNewsTdk:add")
    @Log(title = "日本新闻tdk配置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JapanNewsTdk japanNewsTdk)
    {
        return toAjax(japanNewsTdkService.insertJapanNewsTdk(japanNewsTdk));
    }

    /**
     * 修改日本新闻tdk配置
     */
    @ApiOperation("修改日本新闻tdk配置")
    @RequiresPermissions("ydz:japanNewsTdk:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JapanNewsTdk japanNewsTdk = japanNewsTdkService.selectJapanNewsTdkById(id);
        mmap.put("japanNewsTdk", japanNewsTdk);
        return prefix + "/edit";
    }

    /**
     * 修改保存日本新闻tdk配置
     */
    @ApiOperation("修改保存日本新闻tdk配置")
    @RequiresPermissions("ydz:japanNewsTdk:edit")
    @Log(title = "日本新闻tdk配置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JapanNewsTdk japanNewsTdk)
    {
        return toAjax(japanNewsTdkService.updateJapanNewsTdk(japanNewsTdk));
    }

    /**
     * 删除日本新闻tdk配置
     */
    @ApiOperation("删除日本新闻tdk配置")
    @RequiresPermissions("ydz:japanNewsTdk:remove")
    @Log(title = "日本新闻tdk配置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(japanNewsTdkService.deleteJapanNewsTdkByIds(ids));
    }


    /**
     * 修改保存日本看病新闻配置
     */
    @ApiOperation("修改保存新闻管理")
    @RequiresPermissions("ydz:japanNewsTdk:edit")
    @Log(title = "新闻管理", businessType = BusinessType.UPDATE)
    @PostMapping("/editJapanNewsSet")
    @ResponseBody
    public AjaxResult editJapanNewsSet(@RequestBody List<JapanNewsTdk> list)
    {
        return japanNewsTdkService.editJapanNewsSet(list);
    }
}
